<template>
  <div>
    <a-modal :maskClosable="false" :title="title" centered :width="600" v-model="visible" :footer="null">
      <div class="disFlxAC">
        <div class="disFlxCC _mr-10 _pt-50 _pb-50 hoverBox" @click="openAddMember">
          <div class="fw-6 fz-15">添加为新会员</div>
          <div class="fz-12 _pt-10">若会员不存在, 选这个</div>
        </div>
        <div class="disFlxCC _ml-10 _pt-50 _pb-50 hoverBox" @click="openSearchMember">
          <div class="fw-6 fz-15">与已有会员关联</div>
          <div class="fz-12 _pt-10">会员在系统中已存在, 选这个</div>
        </div>
      </div>
    </a-modal>
    <AddMemberForm
      ref="AddMemberForm"
      :memberLevelOption="memberLevelOption"
      :memberName="currentUser.companyName"
      :leadingAvatar="currentUser.avatar"
      :leadingName="currentUser.name"
      :leadingPhone="currentUser.phone"
      :registerId="registerId"
      @success="handleReload"
    />
    <SearchMember ref="SearchMember" @success="handleReload" :registerId="registerId" />
  </div>
</template>

<script>
import AddMemberForm from '@/views/member/headquarters/modules/addMemberForm'
import SearchMember from './searchMember'
export default {
  components: {
    AddMemberForm,
    SearchMember
  },
  props: ['memberLevelOption', 'registerId'],
  data() {
    return {
      visible: false,
      title: '设为会员',
      currentUser: {}
    }
  },
  methods: {
    show(row) {
      this.visible = true
      this.currentUser = row
      console.log(row);
      
    },
    openAddMember() {
      this.$refs.AddMemberForm.show()
      this.visible = false
    },
    openSearchMember() {
      this.$refs.SearchMember.show(this.currentUser)
      this.visible = false
    },
    // 刷新列表
    handleReload() {
      this.$emit('refresh')
    }
  }
}
</script>

<style lang="less" scoped>
.hoverBox {
  width: 50%;
  border: solid 1px #e5e5e5;
  border-radius: 5px;
  cursor: pointer;
  &:hover {
    color: #1890ff;
    border-color: #1890ff;
  }
}
</style>
